from utils.date_format import datetime_to_str
class WeiboInfo:
    def __init__(self, weibo_id, content, attitudes, comments, reposts, release_time, user_id, **invalid_kwargs):
        """
        数据结构描述
        weibo_id: 博客id
        content: 博客内容
        attitudes: 点赞数
        comments: 评论数
        reposts: 转发数
        times: 发布日期
        两种情况：2024-11-12 09:20:46 或 05月13日 16:31
        统一换成：yyyy-mm-dd hh:mm:ss
        """
        self.weibo_id = weibo_id
        self.content = content
        self.attitudes = attitudes
        self.comments = comments
        self.reposts = reposts
        # 需要判断是否为datetime对象，在数据库拿到的时候要自动转换
        self.release_time = datetime_to_str(release_time)
        self.user_id = user_id
    
    def json(self):
        result = {
            "weibo_id": self.weibo_id,
            "content": self.content,
            "attitudes": self.attitudes,
            "comments": self.comments,
            "reposts": self.reposts,
            "release_time": self.release_time,
            "user_id": self.user_id
        }
        return result
        
        